randomized binary search treeの例文
- Such a data structure is known as a treap or a randomized binary search tree.
- In a randomized binary search tree, the tree after the deletion is equally likely to be either of the two possible trees on its two nodes, independently of what the tree looked like prior to the insertion of the middle number.
- Although the treap and the randomized binary search tree both have the same random distribution of tree shapes after each update, the history of modifications to the trees performed by these two data structures over a sequence of insertion and deletion operations may be different.
- Rather than storing random priorities on each node, the randomized binary search tree stores a small integer at each node, the number of its descendants ( counting itself as one ); these numbers may be maintained during tree rotation operations at only a constant additional amount of time per rotation.
- The deletion procedure for a randomized binary search tree uses the same information per node as the insertion procedure, and like the insertion procedure it makes a sequence of O ( log " n " ) random decisions in order to join the two subtrees descending from the left and right children of the deleted node into a single tree.